#include <gtk/gtk.h>

static GtkWidget *combo_box_with_model()
{
    GtkListStore *store = gtk_list_store_new(1, G_TYPE_STRING);
    GtkWidget *comboBox = NULL;
    GtkTreeIter iter;
    GtkCellRenderer *renderer = gtk_cell_renderer_text_new();

    gtk_list_store_append(store, &iter);
    gtk_list_store_set(store, &iter, 0, "one", -1);
    gtk_list_store_append(store, &iter);
    gtk_list_store_set(store, &iter, 0, "two", -1);
    gtk_list_store_append(store, &iter);
    gtk_list_store_set(store, &iter, 0, "three", -1);

    comboBox = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));

    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(comboBox), renderer, TRUE);
    gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(comboBox), renderer, "text", 0, NULL);


    return comboBox;
}

int main(int argc,char *argv[])
{
    gtk_init(&argc,&argv);

    GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
//    GtkWidget *comboBox = combo_box_with_model();
    GtkWidget *comboBox = gtk_combo_box_new_text();
    GtkWidget *vbox = gtk_vbox_new(TRUE, 1);
    GtkWidget *btn = gtk_button_new_with_label("Finsh");
    GdkColor color_black_ = {0x0, 0x0, 0xFFFF, 0xFFFF};

	/* create the main, top level, window */
	gtk_window_set_title(GTK_WINDOW(window), TITLE);
	gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
	gtk_window_set_default_size(GTK_WINDOW(window), 250, 180);
	gtk_widget_modify_bg(window, GTK_STATE_NORMAL, &color_black_); /*设置为黑色背景*/

    gtk_container_add(GTK_CONTAINER(window), vbox);

    gtk_combo_box_append_text(GTK_COMBO_BOX(comboBox), "one");
    gtk_combo_box_append_text(GTK_COMBO_BOX(comboBox), "two");
    gtk_combo_box_append_text(GTK_COMBO_BOX(comboBox), "three");
    gtk_combo_box_set_active(GTK_COMBO_BOX(comboBox), 0);

    gtk_box_pack_start(GTK_BOX(vbox), comboBox, TRUE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), btn, TRUE, TRUE, 0);

    g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), G_OBJECT(window));

	/* make sure that everything, window and label, are visible */
	gtk_widget_show_all(window);

	/* start the main loop, and let it rest until the application is closed */
	gtk_main();

	return 0;
} 
